﻿using WeShare.WeiXin.Common;
using static System.String;
namespace WeShare.WeiXin.Pay
{
    /// <summary>
    /// 小程序或者微信公众号中发起支付的参数
    /// </summary>
    public class JsReq
    {
        public JsReq(string prepayid, string mchId = "", string subAppId = "")
        {
            this.package = $"prepay_id={prepayid}";
            var payconfig = OpenApi.GetPayConfig(mchId);
            appId = !IsNullOrEmpty(subAppId) ? subAppId : payconfig.AppId;
            this.paySign = Utils.GetPaySign(this, payconfig.PayKey);
        }
        public string appId { get; private set; }
        public string timeStamp { get; set; } = Utils.GetTimeStamp().ToString();
        public string nonceStr { get; set; } = Utils.GetTimeStamp().ToString();
        public string package { get; set; }
        public string signType { get; set; } = "MD5";
        public string paySign { get; set; }
    }
}